
package com.example.moshudriver.protocol;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.external.activeandroid.DataBaseModel;
import com.external.activeandroid.annotation.Column;
import com.external.activeandroid.annotation.Table;

@Table(name = "ordernewpublishResponse")
public class ordernewpublishResponse extends DataBaseModel {

	@Column(name = "user_id")
	public String user_id;

	@Column(name = "offer_price")
	//
	public String offer_price;

	@Column(name = "order_id")
	//
	public String order_id;

	@Column(name = "content")
	public String content;

	@Column(name = "start_location")
	public String start_location;
	@Column(name = "end_location")
	public String end_location;
	@Column(name = "type")
	public String type;

	public void fromJson(String json) throws JSONException {
		JSONArray jsonArray = new JSONObject(json).getJSONArray("message");
		for (int i = 0; i < jsonArray.length(); i++) {
			JSONObject jsonObject = new JSONObject(jsonArray.get(i).toString());
			this.offer_price = jsonObject.get("offer_price").toString();
			this.order_id = jsonObject.get("order_id").toString();
			this.content = jsonObject.get("content").toString();
			this.start_location = jsonObject.get("start_location").toString();
			this.end_location = jsonObject.get("end_location").toString();
			this.user_id = jsonObject.get("user_id").toString();
			this.type = jsonObject.get("type").toString();

		}

	}
}
